package com.rtmart.demo.result;

import lombok.Getter;

@Getter
public class Result {

    public static enum Code{
        SUCCESS(0, "请求成功"),
        ERROR(9999, "请求失败");

        private String message;  
        private Integer index;  

        private Code(Integer index, String message) {
            this.message = message;
            this.index = index;
        }
    }

    private Integer result;
    private String message;
    private Object returnObject;

    public Result(Code code, Object returnObject) {
        this.result = code.index;
        this.message = code.message;
        this.returnObject = returnObject;
    }

    public static Result resultBuilder(Code code, Object returnObject) {
        return new Result(code, returnObject);
    }

    public static Result resultBuilder(Code code) {
        return new Result(code, null);
    }
}